package com.isunland.managesystem.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.ProjectLedger;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

/**
 * 对象功能:  项目台账adapter
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/5/15 13:50
 */

public class ProjectLedgerListAdapter extends BaseButterKnifeAdapter<ProjectLedger> {
  private Context context;

  public ProjectLedgerListAdapter(BaseVolleyActivity context, ArrayList<ProjectLedger> objects) {
    super(context, objects);
    this.context = context;
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_customer_back;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override protected void initView(ProjectLedger item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    MyUtils.switchDataStutus(context, holder.tvStatus, item.getDataStatus());//数据状态
    holder.ivLogo.setImageResource(R.drawable.xiangmutaizhang);
    holder.tvTitle.setText(item.getProjectName());
    holder.tvContent.setText(item.getProjectKindName());
    holder.tvBottom.setText(MyStringUtil.connect(item.getRegStaffName(), " | ", item.getRegDate()));
  }

  protected class ViewHolder extends BaseViewHolder {
    @BindView(R.id.iv_logo) ImageView ivLogo;
    @BindView(R.id.tv_title) TextView tvTitle;
    @BindView(R.id.tv_status) TextView tvStatus;
    @BindView(R.id.tv_content) TextView tvContent;
    @BindView(R.id.tv_bottom) TextView tvBottom;

    ViewHolder(View view) {
      super(view);
      ButterKnife.bind(this, view);
    }
  }
}